package com.lzw.mapper.superAdmin;

import com.lzw.pojo.Suppliers;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SupplierManegeMapper {

    List<Suppliers> list(@Param("name") String name, @Param("phone") String phone, @Param("companyName") String companyName);

    void delete(@Param("ids") List<Integer> ids);

    @Select("SELECT COUNT(*) FROM pharmacymanagement.suppliers WHERE name = #{name}")
    int countByName(String name);

    @Select("SELECT COUNT(*) FROM pharmacymanagement.suppliers WHERE username = #{username}")
    int countByUsername(String username);

    @Select("SELECT COUNT(*) FROM pharmacymanagement.suppliers WHERE phone = #{phone}")
    int countByPhone(String phone);

    @Insert("INSERT INTO pharmacymanagement.suppliers (company_name, name, contact_person, username, password, phone, email) " +
            "VALUES (#{companyName}, #{name}, #{contactPerson}, #{username}, #{password}, #{phone}, #{email})")
    void add(Suppliers suppliers);

    @Select("SELECT * from pharmacymanagement.suppliers WHERE supplier_id = #{id}")
    Suppliers getAdminById(Integer supplierId);

    void update(Suppliers suppliers);
}
